home *** CD-ROM | disk | FTP | other *** search
- function SmallGrid(aRange)
- {
- this.init();
- }
- SmallGrid.prototype.init = function()
- {
- this.pData = new Array(0,0,0,0,0,0,0,0,0);
- };
- SmallGrid.prototype.reorder = function()
- {
- x = 0;
- while(x < 3)
- {
- var _loc3_ = 0;
- y = 0;
- while(y < 3)
- {
- var _loc2_ = x + y * 3;
- if(this.pData[_loc2_] == 0)
- {
- _loc3_ = _loc3_ + 1;
- }
- else if(_loc3_ > 0)
- {
- this.pData[_loc2_ - _loc3_ * 3] = this.pData[_loc2_] + 0;
- this.pData[_loc2_] = 0;
- }
- y++;
- }
- x++;
- }
- };
- SmallGrid.prototype.clearGrid = function()
- {
- var _loc2_ = 0;
- while(_loc2_ < 9)
- {
- this.pData[_loc2_] = 0;
- _loc2_ = _loc2_ + 1;
- }
- };
- SmallGrid.prototype.checkGrid = function()
- {
- var _loc5_ = undefined;
- var _loc4_ = undefined;
- var _loc3_ = undefined;
- var _loc2_ = undefined;
- var _loc6_ = new Array();
- _loc5_ = 0;
- while(_loc5_ < 9)
- {
- _loc4_ = _loc5_ - Math.floor(_loc5_ / 3);
- _loc3_ = _loc5_ % 3;
- _loc2_ = this.getCellColour(_loc4_);
- if(_loc2_ != 0)
- {
- if(this.getCellColour(_loc4_ + 1) == _loc2_ && this.getCellColour(_loc4_ + 2) == _loc2_)
- {
- _loc6_.push(_loc4_,_loc4_ + 1,_loc4_ + 2);
- }
- }
- _loc2_ = this.getCellColour(_loc3_);
- if(_loc2_ != 0)
- {
- if(this.getCellColour(_loc3_ + 3) == _loc2_ && this.getCellColour(_loc3_ + 6) == _loc2_)
- {
- _loc6_.push(_loc3_,_loc3_ + 3,_loc3_ + 6);
- }
- }
- _loc5_ += 4;
- }
- return _loc6_;
- };
- SmallGrid.prototype.removeBlocks = function()
- {
- var _loc9_ = new Array([],[]);
- var _loc10_ = this.pData.slice();
- var _loc3_ = this.pColours.slice();
- var _loc5_ = undefined;
- var _loc2_ = undefined;
- var _loc8_ = undefined;
- var _loc7_ = 6;
- while(_loc7_ < 9)
- {
- _loc5_ = 0;
- _loc2_ = _loc7_ + 0;
- _loc8_ = 0;
- while(_loc2_ >= 0)
- {
- if(_loc10_[_loc2_] == 0)
- {
- if(_loc3_.length == 0)
- {
- _loc3_ = this.pColours.slice();
- }
- else
- {
- var _loc4_ = _loc3_[Math.round(Math.random() * (_loc3_.length - 1))];
- _loc3_.splice(_loc3_.getItemIndex(_loc4_),1);
- }
- var _loc6_ = _loc7_ - 6 + _loc8_ * 3;
- _loc9_[1].push(new Array(_loc2_,_loc6_,_loc4_));
- this.pData[_loc6_] = _loc4_;
- _loc8_ = _loc8_ + 1;
- _loc5_ = _loc5_ + 1;
- }
- else if(_loc5_ > 0)
- {
- _loc9_[0].push(new Array(_loc2_,_loc5_));
- this.pData[_loc2_ + _loc5_ * 3] = _loc10_[_loc2_];
- }
- _loc2_ -= 3;
- }
- _loc7_ = _loc7_ + 1;
- }
- return _loc9_;
- };
- SmallGrid.prototype.checkBlocks = function(tCellNum)
- {
- var _loc12_ = undefined;
- var _loc11_ = undefined;
- var _loc6_ = undefined;
- var _loc14_ = undefined;
- var _loc16_ = undefined;
- var _loc15_ = undefined;
- var _loc17_ = undefined;
- var _loc3_ = undefined;
- var _loc7_ = undefined;
- var _loc8_ = undefined;
- var _loc10_ = undefined;
- var _loc9_ = undefined;
- _loc12_ = new Array();
- _loc11_ = new Array();
- _loc6_ = this.getCellColour(tCellNum);
- _loc14_ = Math.floor(tCellNum / 3);
- _loc16_ = 2 - _loc14_;
- _loc15_ = tCellNum - Math.floor(tCellNum / 3) * 3;
- _loc17_ = 2 - _loc15_;
- _loc7_ = 1;
- while(_loc7_ <= _loc14_)
- {
- _loc3_ = tCellNum - _loc7_ * 3;
- if(this.getCellColour(_loc3_) != _loc6_)
- {
- break;
- }
- _loc11_.push(_loc3_);
- _loc7_ = _loc7_ + 1;
- }
- _loc8_ = 1;
- while(_loc8_ <= _loc16_)
- {
- _loc3_ = tCellNum + _loc8_ * 3;
- if(this.getCellColour(_loc3_) != _loc6_)
- {
- break;
- }
- _loc11_.push(_loc3_);
- _loc8_ = _loc8_ + 1;
- }
- _loc10_ = 1;
- while(_loc10_ <= _loc15_)
- {
- _loc3_ = tCellNum - _loc10_;
- if(this.getCellColour(_loc3_) != _loc6_)
- {
- break;
- }
- _loc12_.push(_loc3_);
- _loc10_ = _loc10_ + 1;
- }
- _loc9_ = 1;
- while(_loc9_ <= _loc17_)
- {
- _loc3_ = tCellNum + _loc9_;
- if(this.getCellColour(_loc3_) != _loc6_)
- {
- break;
- }
- _loc12_.push(_loc3_);
- _loc9_ = _loc9_ + 1;
- }
- var _loc13_ = new Array();
- _loc13_.push(tCellNum);
- if(_loc12_.length >= 2)
- {
- _loc13_ = _loc13_.concat(_loc12_);
- _parent.scores_mc.updateBonus();
- _parent.scores_mc.updateScore(_loc12_.length + 1);
- _parent.fuse_mc.addFuse(_loc12_.length + 1);
- updateBlockCount();
- }
- if(_loc11_.length >= 2)
- {
- _loc13_ = _loc13_.concat(_loc11_);
- _parent.scores_mc.updateBonus();
- _parent.scores_mc.updateScore(_loc11_.length + 1);
- _parent.fuse_mc.addFuse(_loc11_.length + 1);
- updateBlockCount();
- }
- if(_loc13_.length > 1)
- {
- var _loc18_ = _loc13_.length;
- var _loc4_ = 0;
- while(_loc4_ < _loc18_)
- {
- this.pData[_loc13_[_loc4_]] = 0;
- _loc4_ = _loc4_ + 1;
- }
- }
- return _loc13_;
- };
- SmallGrid.prototype.swapBlocks = function(tCellID1, tCellID2)
- {
- var _loc3_ = this.getCellColour(tCellID1);
- var _loc2_ = this.getCellColour(tCellID2);
- this.pData[tCellID1] = _loc2_;
- this.pData[tCellID2] = _loc3_;
- };
- SmallGrid.prototype.fillGrid = function()
- {
- var _loc3_ = undefined;
- var _loc5_ = undefined;
- var _loc6_ = undefined;
- var _loc4_ = undefined;
- var _loc2_ = 0;
- while(_loc2_ < 9)
- {
- _loc3_ = this.pColours.slice();
- if(Math.round(_loc2_ % 3) > 1)
- {
- _loc6_ = this.getCellColour(_loc2_ - 1);
- if(_loc6_ - this.getCellColour(_loc2_ - 2) == 0)
- {
- _loc4_ = _loc3_.getItemIndex(_loc6_);
- _loc3_.splice(_loc4_,1);
- }
- }
- if(Math.floor(_loc2_ / 3) > 1)
- {
- _loc5_ = this.getCellColour(_loc2_ - 3);
- if(_loc5_ - this.getCellColour(_loc2_ - 6) == 0)
- {
- _loc4_ = _loc3_.getItemIndex(_loc5_);
- _loc3_.splice(_loc4_,1);
- }
- }
- this.pData[_loc2_] = _loc3_[Math.round(Math.random() * (_loc3_.length - 1))];
- _loc2_ = _loc2_ + 1;
- }
- };
- SmallGrid.prototype.getCellColour = function(aNum)
- {
- var _loc2_ = this.pData[aNum];
- return _loc2_;
- };
- SmallGrid.prototype.setCellColour = function(aId, aColour)
- {
- this.pData[aId] = aColour + 0;
- };
- SmallGrid.prototype.printGrid = function()
- {
- var _loc3_ = "";
- var _loc4_ = 0;
- while(_loc4_ < 3)
- {
- _loc3_ = "";
- var _loc2_ = 0;
- while(_loc2_ < 3)
- {
- _loc3_ += this.getCellColour(_loc4_ * 3 + _loc2_);
- _loc2_ = _loc2_ + 1;
- }
- _loc4_ = _loc4_ + 1;
- }
- };
- this.init = function()
- {
- this.pGrid = new SmallGrid();
- this.pBlockCount = 0;
- this.pSpaces = new Array(0,0,0,0,0,0,0,0,0);
- this.pTileLocs = new Array(9);
- this.pTileCheck = 0;
- this.pClearedTiles = new Array();
- this.setMask(this.soulMask_mc);
- var _loc3_ = undefined;
- var _loc2_ = 0;
- while(_loc2_ < 9)
- {
- _loc3_ = new Object();
- _loc3_.pNum = _loc2_;
- _loc3_.pPos = new Object();
- _loc3_.pPos.x = -40 + 40 * (_loc2_ % 3);
- _loc3_.pPos.y = 40 - 40 * Math.floor(_loc2_ / 3);
- _loc3_.pColour = _loc2_ + 1;
- this.attachMovie("mc.tile","t" + _loc2_ + "_mc",_loc2_,_loc3_);
- this.pTileLocs[_loc2_] = "t" + _loc2_ + "_mc";
- _loc2_ = _loc2_ + 1;
- }
- };
- this.clearMap = function()
- {
- var _loc2_ = 0;
- while(_loc2_ < 9)
- {
- this[this.pTileLocs[_loc2_]].hideTile();
- this.pSpaces[_loc2_] = 0;
- _loc2_ = _loc2_ + 1;
- }
- this.pBlockCount = 0;
- this.pGrid.clearGrid();
- };
- this.addTile = function(tTileC)
- {
- if(this.pBlockCount < 9)
- {
- this.pBlockCount = this.pBlockCount + 1;
- var _loc2_ = this.pSpaces.getItemIndex(0);
- this[this.pTileLocs[_loc2_]].placeTile(140,tTileC);
- this.pSpaces[_loc2_] = 1;
- this.pGrid.setCellColour(_loc2_,tTileC);
- this.pTileCheck = this.pTileCheck + 1;
- }
- };
- this.tileScaleDone = function()
- {
- if(--this.pTileCheck == 0)
- {
- var _loc8_ = this.pClearedTiles.length / 3;
- var _loc6_ = 0;
- while(_loc6_ < _loc8_)
- {
- var _loc7_ = this.pClearedTiles[_loc6_ * 3];
- if(_loc7_ < 6)
- {
- if(_loc7_ == this.pClearedTiles[_loc6_ * 3 + 1] - 1)
- {
- var _loc4_ = 0;
- while(_loc4_ < 3)
- {
- var _loc5_ = (_loc6_ * 3 + _loc4_) % 3;
- var _loc3_ = 0;
- var _loc2_ = _loc5_;
- while(_loc2_ < _loc5_ + 7)
- {
- if(this.pSpaces[_loc2_] == 0)
- {
- _loc3_ = _loc3_ + 1;
- }
- else if(_loc3_ > 0)
- {
- this[this.pTileLocs[_loc2_]].hideTile();
- this[this.pTileLocs[_loc2_ - _loc3_ * 3]].placeTile(40,this.pGrid.getCellColour(_loc2_));
- this.pSpaces[_loc2_] = 0;
- this.pSpaces[_loc2_ - _loc3_ * 3] = 1;
- this.pTileCheck = this.pTileCheck + 1;
- }
- _loc2_ += 3;
- }
- _loc4_ = _loc4_ + 1;
- }
- this.pGrid.reorder();
- }
- }
- _loc6_ = _loc6_ + 1;
- }
- }
- };
- this.tileDropDone = function()
- {
- if(--this.pTileCheck == 0)
- {
- var _loc3_ = this.pGrid.checkGrid();
- var _loc4_ = _loc3_.length;
- if(_loc4_ > 0)
- {
- this.pClearedTiles.splice(0);
- var _loc2_ = 0;
- while(_loc2_ < _loc4_)
- {
- this[this.pTileLocs[_loc3_[_loc2_]]].scaleTile();
- this.pGrid.setCellColour(_loc3_[_loc2_],0);
- this.pSpaces[_loc3_[_loc2_]] = 0;
- this.pBlockCount = this.pBlockCount - 1;
- this.pClearedTiles.push(_loc3_[_loc2_]);
- this.pTileCheck = this.pTileCheck + 1;
- _loc2_ = _loc2_ + 1;
- }
- if(this._parent._currentframe > 16)
- {
- this._parent.scores_mc.updateScore(100);
- }
- }
- }
- };
- this.init();
- stop();
-